//
//  APSwitchControl.m
//  AqualPolo
//
//  Created by dong on 2024/5/8.
//

#import "APSwitchControl.h"

@implementation APSwitchControl

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = LYRGBColor(8, 23, 78);
        self.layer.cornerRadius = 8;
        self.layer.masksToBounds = true;
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = UIColor.whiteColor;
        _titleLabel.font = [LYFont fontWithSize:12 fontName:LYFontNamepfr];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        [_titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [_titleLabel setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal];
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.bottom.equalTo(self);
        }];
        
        _myswitch = [[UISwitch alloc] init];
        _myswitch.onTintColor = LYRGBColor(87, 61, 255);
        _myswitch.thumbTintColor = UIColor.whiteColor;
        [self addSubview:_myswitch];
        [_myswitch mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(_titleLabel);
        }];
    }
    return self;
}

@end
